package com.relatev.minecraft.TRAttribute;

import com.relatev.minecraft.TRAttribute.listener.TAListener;
import java.util.HashMap;
import org.bukkit.Bukkit;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.LivingEntity;

public class TRACommandManager {

    public static boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        sender.sendMessage("§r------§6TRAttribute§r------");
        if (args.length == 0) {
            sender.sendMessage("§a作者提亚米|QQ1207223090");
            sender.sendMessage("§c/" + label + " help 查阅帮助");
            return true;
        }
        if (args[0].equalsIgnoreCase("help")) {
            sender.sendMessage("§evalues 输出你的属性数值表");
            sender.sendMessage("§evalueMap <TAttribute> 输出指定你属性的valueMap");
        }
        if (sender.hasPermission("TRAttribute.admin")) {
            if (args[0].equalsIgnoreCase("valueMap")) {
                sender.sendMessage(TRAttribute.mainPlugin.getAttributeManager().getEnabledAttributes().get(args[1]).valueMap.get((LivingEntity)sender).toString());
            }
            if (args[0].equalsIgnoreCase("values")) {
                sender.sendMessage("§b输出当前属性存储表: ");
                HashMap<String, TAttribute> attrmap = TRAttribute.mainPlugin.getAttributeManager().getEnabledAttributes();
                for (String id : attrmap.keySet()) {
                    sender.sendMessage("§b" + id + " §r—— §c" + attrmap.get(id).result((LivingEntity) sender).result());
                }
            }
        }
        return true;
    }
}
